package jxtend.processor.eclipse.jdt.dom;

import java.util.List;

import jxtend.processor.eclipse.utils.CGLibProxyUtils;

import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;

public class MarkJxtendGeneratedASTVisitorMethodInterceptor extends AbstractJDTDomASTVisitorMethodInterceptor {

	private final List<ASTNode> astNodes;

	private MarkJxtendGeneratedASTVisitorMethodInterceptor(List<ASTNode> astNodes) {
		this.astNodes = astNodes;
	}

	public static ASTVisitor createASTVisitor(List<ASTNode> astNodes) {
		MarkJxtendGeneratedASTVisitorMethodInterceptor methodInterceptor =
			new MarkJxtendGeneratedASTVisitorMethodInterceptor(astNodes);
		return CGLibProxyUtils.createFromProxy(ASTVisitor.class, methodInterceptor);
	}
	
	@Override
	protected boolean interceptVisit(ASTNode node) {
		astNodes.add(node);

		return true;
	}

	@Override
	protected void interceptEndVisit(ASTNode node) {
		// Do nothing
	}
}
